/*
 * jxSwing Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxSwing.border;

import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxSwing
 * @package org.jxSwing.border
 * @date 21/01/2014 - 20:57:59
 */
public class TitleBorderFactory {
	
	/**
	 * @param border
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final Border border) {
	
		return BorderFactory.createTitledBorder(border);
	}
	
	/**
	 * @param border
	 * @param title
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final Border border, final String title) {
	
		return BorderFactory.createTitledBorder(border, title);
	}
	
	/**
	 * @param border
	 * @param title
	 * @param justification
	 * @param position
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final Border border, final String title, final Justification justification, final Position position) {
	
		return BorderFactory.createTitledBorder(border, title, justification.getValue(), position.getValue());
	}
	
	/**
	 * @param border
	 * @param title
	 * @param justification
	 * @param position
	 * @param titleFont
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final Border border, final String title, final Justification justification, final Position position, final Font titleFont) {
	
		return BorderFactory.createTitledBorder(border, title, justification.getValue(), position.getValue(), titleFont);
	}
	
	/**
	 * @param border
	 * @param title
	 * @param position
	 * @param justification
	 * @param font
	 * @param color
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final Border border, final String title, final Justification justification, final Position position, final Font font, final Color color) {
	
		return BorderFactory.createTitledBorder(border, title, justification.getValue(), position.getValue(), font, color);
	}
	
	/**
	 * @param title
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final String title) {
	
		return createBorder(null, title);
	}
	
	/**
	 * @param title
	 * @param justification
	 * @param position
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final String title, final Justification justification, final Position position) {
	
		return createBorder(null, title, justification, position);
	}
	
	/**
	 * @param title
	 * @param justification
	 * @param position
	 * @param titleFont
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final String title, final Justification justification, final Position position, final Font titleFont) {
	
		return createBorder(null, title, justification, position, titleFont);
	}
	
	/**
	 * @param title
	 * @param position
	 * @param justification
	 * @param font
	 * @param color
	 * @return TitledBorder
	 */
	public static TitledBorder createBorder(final String title, final Justification justification, final Position position, final Font font, final Color color) {
	
		return createBorder(null, title, justification, position, font, color);
	}
	
	/**
	 * @author Denilson Edinaldo Pinto
	 * @porject jxSwing
	 * @package org.jxSwing.border
	 * @date 21/01/2014 - 20:58:35
	 */
	public static enum Justification {
		
		CENTER(TitledBorder.CENTER),
		DEFAULT_JUSTIFICATION(TitledBorder.DEFAULT_JUSTIFICATION),
		LEADING(TitledBorder.LEADING),
		LEFT(TitledBorder.LEFT),
		RIGHT(TitledBorder.RIGHT),
		TRAILING(TitledBorder.TRAILING);
		
		private int value = -1;
		
		/**
		 * @param value
		 */
		private Justification(final int value) {
		
			this.value = value;
		}
		
		/**
		 * @return value
		 */
		public int getValue() {
		
			return value;
		}
	}
	
	/**
	 * @author Denilson Edinaldo Pinto
	 * @porject jxSwing
	 * @package org.jxSwing.border
	 * @date 21/01/2014 - 21:01:04
	 */
	public static enum Position {
		
		ABOVE_BOTTOM(TitledBorder.ABOVE_BOTTOM),
		ABOVE_TOP(TitledBorder.ABOVE_TOP),
		BELOW_BOTTOM(TitledBorder.BELOW_BOTTOM),
		BELOW_TOP(TitledBorder.BELOW_TOP),
		BOTTOM(TitledBorder.BOTTOM),
		DEFAULT_POSITION(TitledBorder.DEFAULT_POSITION),
		TOP(TitledBorder.TOP);
		
		private int value = -1;
		
		/**
		 * @param value
		 */
		private Position(final int value) {
		
			this.value = value;
		}
		
		/**
		 * @return value
		 */
		public int getValue() {
		
			return value;
		}
	}
}
